module derivative_module
	implicit none
contains

	subroutine phyFirstDerivative(xdata, ydata, derivdata)
		implicit none
		real, intent(in), allocatable	:: xdata(:), ydata(:)
		real, intent(out), allocatable	:: derivdata(:)
		integer	:: i, j, n
		n = size(xdata, dim=1)
		allocate(derivdata(n))
		derivdata(1) = 0
		derivdata(n) = 0
		do i = 2, n-1
			derivdata(i) = (ydata(i+1) - ydata(i-1))/(xdata(i+1) - xdata(i-1))
		end do
	end subroutine phyFirstDerivative	 

	subroutine phySecondDerivative(xdata, ydata, derivdata)
		implicit none
		real, intent(in), allocatable	:: xdata(:), ydata(:)
		real,intent(out), allocatable	:: derivdata(:)
		integer	:: i, j, n
		real 	:: temp
		n = size(xdata, dim=1)
		allocate(derivdata(n))
		derivdata(1) = 0
		derivdata(n) = 0
		do i = 2, n-1
			derivdata(i) = (ydata(i+1) - ydata(i))/(xdata(i+1) - xdata(i))
			derivdata(i) = derivdata(i) - (ydata(i) - ydata(i-1))/(xdata(i) - xdata(i-1))
			derivdata(i) = derivdata(i)/(xdata(i) - xdata(i-1))
		end do
	end subroutine phySecondDerivative	 
end module derivative_module